package com.tcs.test.print;

import java.util.HashMap;
import java.util.Map;

import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class PrintTestOne {
	
	private Logger logger = LoggerFactory.getLogger(PrintTestOne.class);
	
	@Test
	public void print1() {
		int a = 2;
		logger.info(" >> {} , << {} " , 1 >> 1 , 1 << 30);
		logger.info(">>> {} " , 10 >>> 2);
		logger.info("|n {} " , a |= 8);
		logger.info("& {} " , a = (3 + 2) & 6);
		logger.info("hashCode {} " , "key".hashCode() ^ "value".hashCode());
		logger.info("key : {} " , hash("1231"));
	}
	
	@Test
	public void hashMapTest() {
//		int size = this.tableSizeFor(50);
//		logger.info(" size : {} " , size);
		Map<String,String> paramMap = new HashMap<String,String>(10 , 0.75f);
		String key = "key";
		for (int i = 1; i <= 1000; i++) {
			logger.info(" {} " , key + i);
			paramMap.put(key + i, null);
		}
	}
	
	int hash(Object key) {
        int h;
        return (key == null) ? 0 : (h = key.hashCode()) ^ (h >>> 16);
    }
	
	static final int MAXIMUM_CAPACITY = 1 << 30;
	
	int tableSizeFor(int cap) {
        int n = cap - 1;
        n |= n >>> 1;
        n |= n >>> 2;
        n |= n >>> 4;
        n |= n >>> 8;
        n |= n >>> 16;
        return (n < 0) ? 1 : (n >= MAXIMUM_CAPACITY) ? MAXIMUM_CAPACITY : n + 1;
    }
}